Ubuntu 安装与卸载 CMake 的几种方式 您所在的位置:网站首页 cmake 安装gmake失败怎么办 Ubuntu 安装与卸载 CMake 的几种方式

Ubuntu 安装与卸载 CMake 的几种方式

2024-07-10 09:46| 来源: 网络整理| 查看: 265

文章目录 apt方式安装添加cmake 官方的key添加主仓库添加候选版本仓库(可选)自动更新仓库的key(可选,推荐!!)安装cmake 卸载 源码方式安装卸载 二进制包方式安装卸载 参考 CMake 常见的安装方式有两种:

apt 安装源码安装二进制包直接安装 apt方式 安装

直接sudo apt install cmake 这样安装的 cmake 多半不是最新版. 推荐方式: 参照官网, 添加cmake 自己的源之后 再cmake 安装就是最新版了.

添加cmake 官方的key wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null 添加主仓库

对于 Ubuntu Focal Fossa (20.04):

sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' sudo apt-get update

对于 Ubuntu Bionic Beaver (18.04):

sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' sudo apt-get update

对于 Ubuntu Xenial Xerus (16.04):

sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main' sudo apt-get update 添加候选版本仓库(可选)

对于Ubuntu Focal Fossa (20.04):

sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal-rc main' sudo apt-get update

对于 Ubuntu Bionic Beaver (18.04):

sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic-rc main' sudo apt-get update

对于 Ubuntu Xenial Xerus (16.04):

sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial-rc main' sudo apt-get update 自动更新仓库的key(可选,推荐!!) sudo apt-get install kitware-archive-keyring sudo rm /etc/apt/trusted.gpg.d/kitware.gpg 安装cmake sudo apt install cmake 卸载

其实这个没啥好说的,就是常规的apt卸载方式. sudo apt remove cmake或者sudo apt purge cmake,前者保留cmake配置文件,后者是卸个干净.

源码方式 安装

去官网下载对应平台的源码,使用tar xvf cmake-xxx.tar.gz 解压.然后进入源码目录,执行:

./bootstrap make make install

./bootstrap可能提示报错:

Error when bootstrapping CMake: Cannot find a C++ compiler that supports both C++11 and the specified C++ flags. Please specify one using environment variable CXX. …

这多半是 g++ 版本过低不支持 C++ 11,执行sudo apt-get install g++ gcc更新一下即可.

make的时候可能报错提示缺少某些依赖,make clean之后,使用 apt 装好即可.常见缺少的依赖:

sudo apt-get install libssl-dev 卸载

参见官方wiki,最简单做法是在源码目录下执行:

sudo xargs rm


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有